package cn.sccl.dirms.monitor.controller;

import cn.sccl.common.zabbix.Zabbix;
import org.springframework.web.bind.annotation.*;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 监控主机
 * Created by liupan on 2017/3/6.
 */
@RestController
@RequestMapping(value = "/dirms/monitor/trend")
public class TrendController {


    /**
     * 获取某一个组的主机数据
     * @param itemid 主机id
     */
    @RequestMapping(value = "/get/{itemid}/{timefrom}/{timefill}", method = {RequestMethod.POST,RequestMethod.GET})
    public List<Map<String,Object>> getTrendByItemId(@PathVariable String itemid, @PathVariable String timefrom, @PathVariable String timefill) {
        Zabbix zabbix = Zabbix.getZabbix();
        Map<String,Object> params = new HashMap<String,Object>();
        params.put("output", "extend");
        params.put("itemids", itemid);
        params.put("time_from", timefrom);
        params.put("time_till", timefill);
        Map<String, Object> result = zabbix.call("trend.get", params);
        List<Map<String, Object>> mapList = (List<Map<String, Object>>) result.get("result");
        return mapList;
    }





}
